<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>合同</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/laydate/skins/default/laydate.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <style>
        * {font-family: "Microsoft Yahei" !important;}
        .header{
            margin-top: 15px;
            height: 40px;
        }
        .header .title{
            margin-left: 22px;
        }
        .header span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .content_label{
            line-height: 28px;
            font-size: 15px;
            color: rgb(111, 111, 111);
        }
        .content_label ul li{
            height: 16px;
            line-height: 16px;
            padding: 5px 12px;
            margin: 25px 0px;
            font-size: 15px;
            border-radius: 3px;
            display: inline;
        }
        .content_label ul{
            margin: 15px 0;
        }

        .pagediv table thead {
            background: white;
            line-height: 40px;
            border-bottom: 1px #dddddd solid;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            height: 50px;
            border: 0px;
        }
        .pagediv tr:hover {
            background-color: #D3E7FA;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .queries{
            padding: 10px 20px;
            height: 40px;
        }
        #pageTbody tr{
            height: 40px;
        }
        #pageTbody tr td{
            /*padding-left: 20px;*/
        }
        .editAndDelete0{
            color: #2b7fe0;
        }
        .editAndDelete1{
            color: #2b7fe0;
        }
        .editAndDelete2{
            color: red;
        }
        #pop-up{
            height: 100%;
            position: fixed;
            top: -2px;
            right: -600px;
            display: none;
        }
        #keyWords{
            padding-left: 5px;
            width: 130px;
            height: 30px;
        }
        #keyWordsNum{
            padding-left: 5px;
            width: 130px;
            height: 30px;
        }
        .index_content_1 .one{
            color: white;
            padding: 4px;
        }
        .index_content_2 .one{
            color: white;
            padding: 4px;
        }

        #supplierImport{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            background-image: url(../../img/import/import.png);
            margin-top: -4px ;
        }
        #supplierExport{
            background-image: url(../../img/import/export.png);
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            margin-top: -4px ;
        }
        .one{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 5px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="header">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">客户合同管理</span>
        <hr style="background-color: black"/>
    </div>
</div>
<div class="queries">
    <label>
        <strong >合同名称:</strong>&nbsp;&nbsp;
        <input  placeholder="请输入合同名称" type="text"  style="padding-left:5px;width: 160px;border-radius: 3px;margin-left:-8px" id="keyWords"/>
        <%--<input  placeholder="请输入合同名称" type="text"  style="border-radius: 3px;margin-bottom: 2px;" id="keyWords"/>--%>
        <%--<input  placeholder="请输入合同总金额" type="text"  style="border-radius: 3px;margin-bottom: 2px;" id="keyWordsNum"/>--%>
        <strong >合同总金额:</strong>&nbsp;&nbsp;
        <input  name="totalMin" id="totalMin" placeholder="最小金额"  type="text"  style="padding-left:5px;width: 160px;border-radius: 3px;margin-left:-8px;height: 30px"/>
        &nbsp;&nbsp;<strong>至</strong>&nbsp;&nbsp;&nbsp;&nbsp;
        <input  name="totalMax"  id="totalMax"  placeholder="最大金额"  type="text"    style="padding-left:5px;width: 160px;border-radius: 3px;margin-left:-8px;height: 30px;"/>

        <button  type="button" class="one" id="query_btn" style="width: 120px">
            <img src="../../img/workflow/worksearch1.png" style="margin-right: 8px;margin-bottom: 2px;"/>查询
        </button>
        <button  type="button" class="one" id="add_btn" style="width: 120px;" onclick="javascript:window.location.href='/crmContract/addContract';">
            <img src="../../img/mywork/newbuildworjk1.png" style="margin-right: 8px;margin-bottom: 2px;"/>新建
        </button>
    </label>
</div>
<div id="pagediv" style="overflow-x: auto;">


</div>

<%--分页--%>
<%--<div class="right" style="margin-right: 7%;">
    <div style="margin: 0 auto;height:50px;width: 97%;" class="clearfix">
        <div style="margin: 0 auto;height:50px;width: 97%;" class="clearfix">
            <div id="dbgz_page" class="M-box3">

            </div>
        </div>
    </div>
</div>--%>
</body>
<script>
    var pageObj ;
    //tab切换
    $('.clearfix').on('click','li',function(){
        $(".clearfix li").removeClass("change");
        $(this).addClass('change');
        if($(this).attr('id')=='biaodan'){
            $('.news').html('<fmt:message code="workflow.th.tablesort" />');
            $('.flow_img').attr('src','/img/commonTheme/${sessionScope.InterfaceModel}/form_img.png');
            $('.tab_tone').css("display","block");
            $('.tab_ttwo').css("display","none");
            $('.sort_liucheng h1').html('<fmt:message code="workflow.th.tablelist" />');
            $('.new_liucheng').attr('data-numtrue',1)

        }else {
            $('.news').html('<fmt:message code="workflow.th.process" />');
            $('.flow_img').attr('src','/img/commonTheme/${sessionScope.InterfaceModel}/flow_img.png');
            $('.tab_ttwo').css("display","block");
            $('.tab_tone').css("display","none");
            $('.sort_liucheng h1').html('<fmt:message code="workflow.th.processlist" />');
            $('.new_liucheng').attr('data-numtrue',2)
        }
    });
    //        tab切换
    $(".content_label").on("click","li",function(){
        $(this).siblings('li').removeClass("active");
        $(this).addClass('active');
        if($(this).attr('class')=='index_content_1'){
            $('.main').find('iframe').prop('src','/..../');
        }else if($(this).attr('class')=='index_content_2'){
            $('.main').find('iframe').prop('src','/..../');
        }else{
            $('.main').find('iframe').prop('src','/..../');
        }
    });
    $(function () {
        var startTime=new Date().Format('yyyy-MM');
        var bodyWidth=2400;
        //表格数据初始化展示
        var pageObj = $.tablePage('#pagediv', '1650px', [
            {
                width: '100px',
                title: '合同编号',
                name: 'contractNo'
            },
            {
                width: '100px',
                title: '合同名称',
                name: 'contractName'
            },
            {
                width: '100px',
                title: '合同内容',
                name: 'content'

            },/* {
                width: '100px',
                title: '客户编号',
                name: 'customerNo'

            },*/ {
                width: '100px',
                title: '客户名称',
                name: 'customerName'
            },
            {
                width: '90px',
                title: '合同类型',
                name: 'type',
                selectFun: function (arriveTime, obj) {

                    var thiss = '';
                    if (obj.type == '01') {
                        thiss = '产品销售';
                    } else if(obj.type == '02'){
                        thiss = '业务销售';
                    }else if(obj.type == '03'){
                        thiss = '售后销售';
                    }else if(obj.type == '04'){
                        thiss = '代理分销';
                    }else if(obj.type == '05'){
                        thiss = '其他';
                    }
                    return  thiss;
                }
            },
            {
                width: '80px',
                title: '合同状态',
                name: 'status',
                selectFun: function (arriveTime, obj) {

                    var thiss = '';
                    if (obj.status == '0') {
                        thiss = '执行中';
                    } else if(obj.status == '1'){
                        thiss = '结束';
                    }else if(obj.status == '2'){
                        thiss = '意外终止';
                    }
                    return  thiss;
                }
            },
            /*{
                width: '100px',
                title: '合同责任人',
                name: 'approvalUser'

            },*/
            /*{
                width: '100px',
                title: '合同备注',
                name: 'remark'

            },*/
            {
                width: '100px',
                title: '总金额',
                name: 'total'

            },
            {
                width: '100px',
                title: '已到款金额',
                name: 'receivedMoney'

            },
            {
                width: '70px',
                title: '付款方式',
                name: 'payWay',
                selectFun: function (arriveTime, obj) {
                    var thiss = '';
                    if (obj.payWay == '01') {
                        thiss = '现金';
                    } else if(obj.payWay == '02'){
                        thiss = '转账';
                    }else if(obj.payWay == '03`'){
                        thiss = '支票';
                    }else if(obj.payWay == '04'){
                        thiss = '支付宝';
                    }else if(obj.payWay == '05'){
                        thiss = '微信';
                    }else if(obj.payWay == '06'){
                        thiss = '其他';
                    }
                    return  thiss;
                }
            },
            {
                width: '100px',
                title: '合同有效期',
                name: 'validTime',
                selectFun: function (validTime, obj) {
                    if(obj.validTime==undefined){
                        return " "
                    }else{
                        return obj.validTime
                    }

                }
            },
            {
                width: '100px',
                title: '审批状态',
                name: 'approvalStatus',
                selectFun: function (arriveTime, obj) {
                    var thiss = '';
                    if (obj.approvalStatus == '0') {
                        thiss = '待审批';
                    } else if(obj.approvalStatus == '1'){
                        thiss = '已通过';
                    }else if(obj.approvalStatus == '2`'){
                        thiss = '已驳回';
                    }
                    return  thiss;
                }
            },
            {
                width: '100px',
                title: '创建人',
                name: 'creator'
            },
            {
                width: '100px',
                title: '创建时间',
                name: 'createTime'
            },
            {
                width: '100px',
                title: '<fmt:message code="menuSSetting.th.menuSetting"/>',
            }
        ], function (me) {
            me.data.flag = 0;
            me.data.pageSize = 10;
            me.init('/crmContract/selectCrmContract', [
                {
                    name: '详情',
                }, {
                name: '编辑',
            }, {
                name: '删除'
            }
            ],function () {
                // 获取合同名称进行模糊查询
                $('#query_btn').click(function () {
                    /*var keyWords=$('#keyWords').val();
                    var keyWordsNum=$('#keyWordsNum').val();
                    me.data.contractName = keyWords;
                    me.data.total = keyWordsNum;
                    //每次模糊查询时初始化页码从第一页开始查询
                    me.data.page = 1;
                    me.init("/crmContract/selectCrmContract");*/
                    var keyWords=$('#keyWords').val();
                    me.data.contractName = keyWords;
                    if($('#totalMin').val()!=""&&$('#totalMax').val()!=""){
                        me.data.totalMin=$('#totalMin').val();
                        me.data.totalMax=$('#totalMax').val();
                    }else if($('#totalMin').val()==""&&$('#totalMax').val()!=""){
                        me.data.totalMin=$('#totalMin').val();
                        me.data.totalMax=$('#totalMax').val();
                    }else if($('#totalMin').val()!=""&&$('#totalMax').val()==""){
                        me.data.totalMin=$('#totalMin').val();
                        me.data.totalMax=$('#totalMax').val();
                    }else{
                        me.data.totalMin=undefined
                        me.data.totalMax=undefined
                    }
                    //每次模糊查询时初始化页码从第一页开始查询
                    me.data.page = 1;
                    me.init("/crmContract/selectCrmContract");
                })
                $('.page-top-inner-layer table tr').eq(0).css('background-color','#FFFFFF')

            })
        })
        // 根据id合同数据详情
        $('#pageTbody').on('click','.editAndDelete0',function(){
            var contractId = pageObj.arrs[$(this).attr('data-i')].contractId;
            window.location.href = '/crmContract/detailsContract?contractId='+contractId;
        });
        // 根据id编辑合同数据
        $('#pageTbody').on('click','.editAndDelete1',function(){
            var contractId = pageObj.arrs[$(this).attr('data-i')].contractId;
            window.location.href = '/crmContract/updateContract?contractId='+contractId;
        });

        // ajax 根据产品信息表[crm_product]的主键id进行删除数据
        $('#pageTbody').on('click','.editAndDelete2',function(){
            var contractId=pageObj.arrs[$(this).attr('data-i')].contractId;
            layer.confirm(qued,{
                btn: [sure,cancel], //按钮
                title:'确定删除？'
            }, function(){
                $.ajax({
                    type:'post',
                    url:'/crmContract/deleteCrmContractById',
                    dataType:'json',
                    data:{'contractId':contractId},
                    success:function(json){
                        if(json.flag==true){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                window.location.href="/crmContract/index"
                            })
                        }else {
                            layer.msg("删除失败",{
                                icon: 2,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                window.location.href='/crmContract/index'
                            })
                        }
                    }
                })
            });
        });
    });
</script>
</html>
